package com.dkd.model.auth.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dkd.model.auth.VO.UserVO;
import com.dkd.model.auth.entity.*;
import com.dkd.model.auth.mapper.*;
import com.dkd.model.auth.service.*;
import com.dkd.model.base.utils.PageUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {

	@Override
	public PageUtil<SysUser> selectPageListBySql(UserVO userVO) {
		PageHelper.startPage(userVO.getCurrent(), userVO.getSize(), true);
		//用mapper查询
		//List<SysUser> list = baseMapper.selectPageListBySql(userVO);
		//用标签查询
		List<SysUser> list = baseMapper.selectListBySQL(userVO);
		PageInfo<SysUser> pageInfo = new PageInfo<SysUser>(list);
		Long count = pageInfo.getTotal();
		PageUtil<SysUser> pageData = new PageUtil<SysUser>(userVO.getCurrent(), userVO.getSize(), count);
		pageData.setRecords(list);
		return pageData;
	}

	@Override
	public List<SysUser> selectListBySql(UserVO userVO) {
		//不过滤查询条件
		List<SysUser> list2 = baseMapper.selectPageListBySql(userVO);
		//过滤查询条件
		List<SysUser> list = baseMapper.selectListBySQL(userVO.getUsername(),userVO.getPassword());
		return list;
	}
}
